/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
+function($) {
   $(window).scroll(function () {        	
        if ($(window).scrollTop() === ( $(document).height() - $(window).height())) {
            loadData();
        }
    });
}(window.jQuery);

function loadData() {
//    var geocodingAPI = "http://youlike.com/demo/loaddata";
	var geocodingAPI = "http://localhost/youlike/main/loaddata";
    var body = $("body");
    body.addClass("loading");
    $.getJSON(geocodingAPI, function(json) {
        var id;
        var name;
        var desc;
        for (var i=0; i<3; i++) {
            id = json[i].id;
            name = json[i].name;
            desc = json[i].desc;
            $('.main-item').eq(0).append('<div class="thumbnail"><a href="#project-link"><img class="img-responsive" src="http://images.hotdeals.vn/images/detailed/282/51093_slide_(1).jpg"></a><h3><a href="#project-link">' + name + '</a></h3><p>' + desc + '</p></div>');
        }
        for (var i=3; i<6; i++) {
            id = json[i].id;
            name = json[i].name;
            desc = json[i].desc;
            $('.main-item').eq(1).append('<div class="thumbnail"><a href="#project-link"><img class="img-responsive" src="http://images.hotdeals.vn/images/detailed/282/51093_slide_(1).jpg"></a><h3><a href="#project-link">' + name + '</a></h3><p>' + desc + '</p></div>');
        }
        for (var i=6; i<9; i++) {
            id = json[i].id;
            name = json[i].name;
            desc = json[i].desc;
            $('.main-item').eq(2).append('<div class="thumbnail"><a href="#project-link"><img class="img-responsive" src="http://images.hotdeals.vn/images/detailed/282/51093_slide_(1).jpg"></a><h3><a href="#project-link">' + name + '</a></h3><p>' + desc + '</p></div>');
        }
        body.removeClass("loading");
    });
}